package com.four.bmm.service;

import com.four.bmm.dao.IReplyDao;
import com.four.bmm.entity.Reply;
import com.four.bmm.util.Pagnation;
import com.four.bmm.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class ReplyService {
    SqlSession session=SqlSessionFactoryUtil.getSqlSession();
    IReplyDao replyDao=session.getMapper(IReplyDao.class);
    public Pagnation<Reply> getNewsReplyListByPage(int newsid,int pageNo){
        List<Reply> list=replyDao.getNewsReplyListByPage(newsid,(pageNo-1)*Pagnation.pageSize,Pagnation.pageSize);
        Pagnation<Reply> pg=new Pagnation<Reply>();
        pg.setPageNo(pageNo);
        pg.setList(list);
        pg.setTotalRows(replyDao.getTotalRows(newsid));
        return pg;
    }
}
